if (!m_pOptions->ParseOptionsCommand(pData, nDataLength, bLocal))
{
pAdminSocket->SendCommand(1, 1, "\001Protocol error: Invalid data, could not import settings.", strlen("\001Protocol error: Invalid data, could not import settings.")+1);
char buffer = 1;
pAdminSocket->SendCommand(1, 5, &buffer, 1);
break;
}
char buffer = 0;
pAdminSocket->SendCommand(1, 5, &buffer, 1);
unsigned int threadnum = (int)m_pOptions->GetOptionVal(OPTION_THREADNUM);
if (m_nServerState & STATE_ONLINE)
{
if (threadnum > m_ThreadArray.size())
{
int newthreads = threadnum - m_ThreadArray.size();
for (int i = 0; i < newthreads; i++)
{
int index = GetNextThreadNotificationID();
CServerThread *pThread = new CServerThread(WM_FILEZILLA_SERVERMSG + index);
m_ThreadNotificationIDs[index] = pThread;
if (pThread->Create(THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED))
{
pThread->ResumeThread();
m_ThreadArray.push_back(pThread);
}
}
CStdString str;
str.Format(_T("Number of threads increased to %d."), threadnum);
ShowStatus(str, 0);
}
else if (threadnum < m_ThreadArray.size())
{
CStdString str;
str.Format(_T("Decreasing number of threads to %d."), threadnum);
ShowStatus(str, 0);
unsigned int i=0;
std::list<CServerThread *> newList;
for (std::list<CServerThread *>::iterator iter=m_ThreadArray.begin(); iter!=m_ThreadArray.end(); iter++,i++)
pAdminSocket->SendCommand(1, 1, "\001Protocol error: Unexpected data length", strlen("\001Protocol error: Unexpected data length")+1);
else
{
CPermissions permissions;
if (!permissions.ParseUsersCommand(pData, nDataLength))
{
pAdminSocket->SendCommand(1, 1, "\001Protocol error: Invalid data, could not import account settings.", strlen("\001Protocol error: Invalid data, could not import account settings.")+1);
int nAdminPort = (m_pOptions ? (int)m_pOptions->GetOptionVal(OPTION_ADMINPORT) : 14147);
CStdString error;
if (!DoCreateAdminListenSocket(nAdminPort, (ipBindings != _T("*")) ? _T("127.0.0.1") : NULL, AF_INET))
{
int p = DoCreateAdminListenSocket(nAdminPort, _T("127.0.0.1"), AF_INET);
if (!p)
{
CStdString str;
str.Format(_T("Failed to create listen socket for admin interface on port %d for IPv4, the IPv4 admin interface has been disabled."), nAdminPort);
ShowStatus(str, 1);
error += _T("\n") + str;
}
else
{
CStdString str;
str.Format(_T("Failed to create listen socket for admin interface on port %d for IPv4, for this session the IPv4 admin interface is available on port %u."), p);
ShowStatus(str, 1);
error += _T("\n") + str;
}
}
if (!m_pOptions->GetOptionVal(OPTION_DISABLE_IPV6))
{
if (!DoCreateAdminListenSocket(nAdminPort, (ipBindings != _T("*")) ? _T("::1") : NULL, AF_INET6))
{
int p = DoCreateAdminListenSocket(nAdminPort, _T("127.0.0.1"), AF_INET6);
if (!p)
{
CStdString str;
str.Format(_T("Failed to create listen socket for admin interface on port %d for IPv6, the IPv6 admin interface has been disabled."), nAdminPort);
ShowStatus(str, 1);
error += _T("\n") + str;
}
else
{
CStdString str;
str.Format(_T("Failed to create listen socket for admin interface on port %d for IPv6, for this session the IPv6 admin interface is available on port %u."), p);
ShowStatus(str, 1);
error += _T("\n") + str;
}
}
}
if (ipBindings != _T("*"))
{
if (ipBindings != _T(""))
ipBindings += _T(" ");
while (ipBindings != _T(""))
{
int pos = ipBindings.Find(' ');
if (pos == -1)
break;
CStdString ip = ipBindings.Left(pos);
ipBindings = ipBindings.Mid(pos+1);
CAdminListenSocket *pAdminListenSocket = new CAdminListenSocket(m_pAdminInterface);
int family;
if (ip.Find(':') != -1)
family = AF_INET6;
else
family = AF_INET;
if (!pAdminListenSocket->Create(nAdminPort, SOCK_STREAM, FD_ACCEPT, ip, family) || !pAdminListenSocket->Listen())